<%@page import="java.util.ArrayList"%>
<%@page import="test.Topic"%>
<%@page import="java.util.List"%>
<%@page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; UTF-8">
<title>TEST BLOG</title>
</head>
<body>
<h1>TEST BLOG</h1>

<%-- 登録用フォーム --%>

<form method="POST" action="/WebSample/post">
<input size=50 type="text"  name="title"></input>
<br></br>
<textarea name="message" cols=50></textarea>
<input type="submit" value="投稿">
</form>
<%-- エラーの表示 --%>
<%
String errorMessage = (String)request.getAttribute("errorMessage");
if (errorMessage != null){
%>
<H2>
<%= errorMessage %>
</H2>
<%
}
%>
<br></br><br></br><br></br>

<%-- ループ処理で記事を表示 --%>

<%
 List<Topic> listTopic = (List<Topic>)request.getAttribute("listTopic");
 int i = 0;
 Topic topic = null;
 for ( i = 0 ; i < listTopic.size(); i++) {
 topic = (Topic) listTopic.get(i);
 %>
<table border=1 width=50% align=center>
<tr align="right"><th><%= topic.getTime() %></th></tr>
<tr align="center"><th><%= topic.getTitle() %></th></tr>
<tr align="left"><th><%= topic.getMessage() %></th></tr>
<tr align="right"><th><%= topic.getUser() %></th></tr>
</table>
<br></br>
<%
  }
%>

</body>
</html>